#include "libraries.h"

Player::Player()
{
    imgLocation = "Images/Ship/shipCenterNew2.png";
    imgLoadAlpha(image, imgLocation);
    dX    = 0.0;
    dY    = 0.0;
    updatePos();
    setRect();
    lives = 5;
    maxAmmo       = 1;  /* Higher numbers = more ammo */
    ammoDelay     = 5;/* Lower numbers = faster rate of fire */
    ammoVelocity  = 7;  /* Higher numbers = faster projectile velocity */
    ammoType      = 1;  /* Used in determining what ammunition player fires */
    movementSpeed = 3;  /* Higher numbers = faster player movement */
    points        = 0;
    ammoCooldown  = 0;  /* Keeps track of the delay on ammo */
    isDead        = false;
}

Player::Player(Sint16 coordX, Sint16 coordY, string imageLocation)
{
    imgLoadAlpha(image, imageLocation.c_str() );
    imgLocation   = imageLocation;
    dX            = 1.0 * coordX;
    dY            = 1.0 * coordY;
    updatePos();
    setRect();
    lives         = 5;
    maxAmmo       = 1; /* Higher numbers = more ammo */
    ammoDelay     = 5;  /* Lower numbers = faster rate of fire */
    ammoVelocity  = 7;  /* Higher numbers = faster projectile velocity */
    ammoType      = 1;  /* Used in determining what ammunition player fires */
    movementSpeed = 3;  /* Higher numbers = faster player movement */
    points        = 0;
    ammoCooldown  = 0;  /* Keeps track of the delay on ammo */
    isDead        = false;
}

Player::Player(const Player& other)
{
    imgLoadAlpha(image, (other.imgLocation).c_str() );
    imgLocation   = other.imgLocation;
    dX            = other.pos.x;
    dY            = other.pos.y;
    updatePos();
    setRect();
    lives         = other.lives;
    maxAmmo       = other.maxAmmo;
    ammoDelay     = other.ammoDelay;
    ammoVelocity  = other.ammoVelocity;
    movementSpeed = other.movementSpeed;
    points        = other.points;
    ammoCooldown  = other.ammoCooldown;
    isDead        = other.isDead;
}

const Player& Player::operator =(const Player &other)
{
    if(this != &other)
    {
        imgLoadAlpha(image, (other.imgLocation).c_str() );
        imgLocation   = other.imgLocation;
        dX            = other.pos.x;
        dY            = other.pos.y;
        updatePos();
        setRect();
        lives         = other.lives;
        maxAmmo       = other.maxAmmo;
        ammoDelay     = other.ammoDelay;
        ammoVelocity  = other.ammoVelocity;
        movementSpeed = other.movementSpeed;
        points        = other.points;
        ammoCooldown  = other.ammoCooldown;
        isDead = other.isDead;
    }
    return *this;
}

Player::~Player()
{
    if(image) SDL_FreeSurface(image);
}

void Player::move(Uint8* keyinput)
{
    //int sizeOfAmmo = ammunition.getSize();
    /* Movement */
    double boost = 1.0; /* Boost is a speed modifier.  Higher values = faster movement */
    if(keyinput[SDLK_LSHIFT] || keyinput[SDLK_RSHIFT]) boost = 2.0; /* If player holds down boost key, go faster */
    if( (keyinput[SDLK_LEFT] && pos.x > 0) && !keyinput[SDLK_RIGHT] )
    {
        dX = dX - static_cast<double>(movementSpeed) / ACCURACY_CHECK * boost;
    }

    else if( (keyinput[SDLK_RIGHT] && pos.x + pos.w < SCREEN_WIDTH) && !keyinput[SDLK_LEFT] )
    {
        dX = dX + static_cast<double>(movementSpeed) / ACCURACY_CHECK * boost;
    }

    if( (keyinput[SDLK_UP] && pos.y > SCREEN_HEIGHT*4/5) && !keyinput[SDLK_DOWN] )
    {
        dY = dY - static_cast<double>(movementSpeed) / ACCURACY_CHECK * boost;
    }

    else if( (keyinput[SDLK_DOWN] && pos.y + pos.h < SCREEN_HEIGHT) && !keyinput[SDLK_UP] )
    {
        dY = dY + static_cast<double>(movementSpeed) / ACCURACY_CHECK * boost;
    }
    updatePos();

    /* Shot fired */
    if(keyinput[SDLK_SPACE] && ammoCooldown <= 0 && maxAmmo > ammunition.getSize())
    {
        ammoCooldown = ammoDelay; /* Reset ammoCooldown */
        ammunition.pushFront(Ammo(*this, ammoType));
    }
    else ammoCooldown -= 1.0 / ACCURACY_CHECK;
    for(int i=0; i < ammunition.getSize(); i++)
    {
        if( ammunition[i].getY() >= SCREEN_HEIGHT || ammunition[i].getY() <= 0 ||
            ammunition[i].getX() >= SCREEN_WIDTH  || ammunition[i].getX() <= 0)
        {
            ammunition.popElement(i);
            i--; /* Needed to preserve current index of ammunition */
        }
        else ammunition[i].move(ammoVelocity);
    }
}

Ammo::Ammo()
{
    idNumber = 0;
    image = NULL;
    imgLocation = "Images/Ammunition/missileDefault.png"; //Delete this
    imgLoadAlpha(image, imgLocation); /* Default image */
    dX = 0.0;
    dY = 0.0;
    updatePos();
    setRect();
}

Ammo::Ammo(Player& obj, int type)
{
    idNumber = type;
    image = NULL;
    if(idNumber == 1) imgLocation = "Images/Ammunition/missileDefault.png";
    else imgLocation = "Images/Ammunition/missileDefault.png"; /* Load default if all else fails */
    imgLoadAlpha(image, imgLocation);
    dX = obj.getDX();
    dY = obj.getDY();
    updatePos();
    setRect();
}

Ammo::Ammo(const Ammo& other)
{
    idNumber    = other.idNumber;
    image       = NULL; /* Preventative measures are yummy */
    imgLocation = other.imgLocation;
    imgLoadAlpha(image, imgLocation);
    dX          = other.dX;
    dY          = other.dY;
    updatePos();
    setRect();
}

const Ammo& Ammo::operator= (const Ammo& other)
{
    if(this != &other)
    {
        idNumber    = other.idNumber;
        image       = NULL; /* Preventative measures are yummy */
        imgLocation = other.imgLocation;
        imgLoadAlpha(image, imgLocation);
        dX          = other.dX;
        dY          = other.dY;
        updatePos();
        setRect();
    }
    return *this;
}

Ammo::~Ammo()
{
    if(image) SDL_FreeSurface(image);
}

void Ammo::move(int velocity)
{
    if( idNumber == 1)
    {
        dY -= static_cast<double>(velocity) / ACCURACY_CHECK;
        updatePos();
    }
}

void makeEnemy(list<Enemy>& enemy, string enemyName)
{
    int enemyIndex = enemy.getSize(); /* This works because Enemy is pushed to back of list after this assignment */
    /*Enemy(parent, idNumber=0, health=0, value=0, model="Images/defaultModel", ammoCooldown=0,
            damage=0, modelRotation+180=0, selfDamage=500, changeDifficulty=true)*/
    /*DO NOT EVER INCLUDE THE FILE EXTENSION.  ALL IMAGES ARE .png AND YOU WILL MESS ROTATION UP IF YOU INCLUDE THE EXTENSION */
    if(enemyName == "spiderLeft")
    {
        enemy.pushBack(Enemy(1, 1, 1000, "Images/Enemies/spider", 0, 400, 0, 0, true));
        enemy[enemyIndex].setX(0); /* Start on left or right of screen */
        enemy[enemyIndex].setY(rand() % (SCREEN_HEIGHT/10)+SCREEN_HEIGHT*7/10);  /* Start in top third of screen */
    }
    if(enemyName == "spiderRight")
    {
        enemy.pushBack(Enemy(2, 1, 1000, "Images/Enemies/spider", 0, 400, 0, 0, true));
        enemy[enemyIndex].setX(SCREEN_WIDTH); /* Start on left or right of screen */
        enemy[enemyIndex].setY(rand() % (SCREEN_HEIGHT/10)+SCREEN_HEIGHT*7/10);  /* Start in top third of screen */
    }
    else if(enemyName == "flea")
    {
        enemy.pushBack(Enemy(3, 1, 750, "Images/Enemies/flea", 0, 400, 0, 0, true));
        enemy[enemyIndex].setX((rand() % (SCREEN_WIDTH-40) + 20)); /* Starts at least 20 away from sides */
        enemy[enemyIndex].setY(0); /* Always starts at the top of the screen */
    }
    else if(enemyName == "mushroom")
    {
        enemy.pushBack(Enemy(4, 4, 40, "Images/Enemies/mushroom", 0, 0, 0, 0, false));
        enemy[enemyIndex].setX((rand() % (SCREEN_WIDTH /35))*35); /* Mushrooms spawn spaced 20 pixels apart */
        enemy[enemyIndex].setY((rand() % (SCREEN_HEIGHT*4/5/35))*35); /* Mushrooms spawn spaced 20 pixels apart */
        enemy[enemyIndex].setAmmoCooldown(0);
    }
    else if(enemyName == "scorpionLeft") /* Starts at left and moves right */
    {
        enemy.pushBack(Enemy(5, 1, 1000, "Images/Enemies/scorpion", 0, 400, 0, 0, true));
        enemy[enemyIndex].setX(0);
        enemy[enemyIndex].setY((rand() % (SCREEN_HEIGHT/4))+40);
    }
    else if(enemyName == "scorpionRight") /* Starts at right and moves left */
    {
        enemy.pushBack(Enemy(6, 1, 1000, "Images/Enemies/scorpion", 0, 400, 0, 0, true));
        enemy[enemyIndex].setX(SCREEN_WIDTH);
        enemy[enemyIndex].setY((rand() % (SCREEN_HEIGHT/4))+40);
    }
    /*centipedeHead AND centipedeBody ARE ONLY FOR A FRAME OF REFERENCE.  DO NOT EVER CALL THESE WITH THE
      makeEnemy FUNCTION.  YOU HAVE BEEN WARNED!!!
    else if(enemyName == "centipedeHead")
    {
        enemy.pushBack(Enemy(7, 1, 500, "Images/Enemies/centipede", 0, 400, 0, 0, true));
        enemy[enemyIndex].setX(0);
        enemy[enemyIndex].setY(0);
    }
    else if(enemyName == "centipedeBody")//Body of the centipede
    {
        enemy.pushBack(Enemy(8, 1, 500, "Images/centipedeBody", 0, 400, 0, 0,true));
        enemy[enemyIndex].setX(0);
        enemy[enemyIndex].setY(0);
    }*/
}

void createEnemies(list<Enemy>& enemy, string enemyName, int countAmount)
{
    int listNumber = enemy.getSize(); /* Counts number of enemies that exist */
    int availableEnemies = MAX_ENEMIES - listNumber; /* Number of enemies able to make */
    if(availableEnemies < countAmount && availableEnemies > 0) countAmount -= availableEnemies; /* If not enough room to make all enemies */
    else if(availableEnemies <= 0) countAmount = 0;
    for(int i=0; i < countAmount; i++) /* Keeps number of enemies below MAX_ENEMIES */
    {
        makeEnemy(enemy, enemyName);
    }
}

void createEnemiesQueue(Uint32 curTime, list<Enemy>& enemy, string enemyName, int countAmount, int cooldownTime, int number)
{
    /* Number of -1 is used for continuous streams of enemies until the level ends */
    if(curTime % static_cast<Uint32>(cooldownTime) == 0 && curTime > 0 && number == -1) createEnemies(enemy, enemyName, countAmount);
    else if(curTime % static_cast<Uint32>(cooldownTime) == 0 && curTime > 0 && curTime <= static_cast<Uint32>(cooldownTime * number)) createEnemies(enemy, enemyName, countAmount);
}

Enemy::Enemy(int idNum, int hp, int val, string model, int ammoCool, int dmg, int modelRotation, int selfDmg, bool changeDifficulty)
{
    image = NULL; /* Helps to prevent possible breakage */
    idNumber    = idNum;
    //if(changeDifficulty) health = hp + int(1.0 * health*(difficultyMultiplier-defaultMultiplier)); /* Hard mode has double HP */
    health = hp;
    healthMax   = health; /* Set max HP of enemy to curretn HP */
    //value  = val + int(1.0*val*(difficultyMultiplier-defaultMultiplier));
    value = val;

    /* Ghetto rotation */
    if(modelRotation < 0) modelRotation = 360 - ((modelRotation * -1) % 360); /* Negative check */
    if     (modelRotation % 360 == 90 ) imgLocation = model + "Left.png";
    else if(modelRotation % 360 == 180) imgLocation = model;
    else if(modelRotation % 360 == 270) imgLocation = model + "Right.png";
    else                                imgLocation = model + "Down.png";
    imgLoadAlpha(image, imgLocation);
    pos.x = 0; /* X and Y are set outside of constructor */
    pos.y = 0;
    setRect();
    damage         = dmg;
    selfDamage     = selfDmg;
    offset         = rand() % 101 - 50; /* Offset is used in AI.  Must be included here. */
}

Enemy::~Enemy()
{
    if(image) SDL_FreeSurface(image);
}

int Enemy::move(list<Enemy>& enemy,int index, Uint32 frame)
{
    int indexChange=0; /*Keeps track of changes in index*/
    /*ID 1 (SpiderLeft)*/
    if(idNumber==1)
    {
        int movement = (frame+(offset+50)*2) % 180;
        if(movement >= 0 && movement < 20)
        {
            dX += 1.0 * (4 + offset%2) / ACCURACY_CHECK;
            dY -= 1.0 * (4 + offset%3) / ACCURACY_CHECK;
        }
        else if(movement >= 20 && movement < 40)
        {
            dX += 1.0 * (4 + offset%3) / ACCURACY_CHECK;
            dY += 1.0 * (4 + offset%2) / ACCURACY_CHECK;
        }
        else if(movement >= 40 && movement < 60)
        {
            dY -= 1.0 * (5 + offset%3) / ACCURACY_CHECK;
        }
        else if(movement >= 60 && movement < 80)
        {
            dY += 1.0 * (5 + offset%2) / ACCURACY_CHECK;
        }
        else if(movement >= 80 && movement < 100)
        {
            dX += 1.0 * (4 + offset%4) / ACCURACY_CHECK;
            dY += 1.0 * (4) / ACCURACY_CHECK;
        }
        else if(movement >= 100 && movement < 120)
        {
            dX += 1.0 * (4 + offset%2) / ACCURACY_CHECK;
            dY -= 1.0 * (4 + offset%2) / ACCURACY_CHECK;
        }
        else if(movement >= 120 && movement < 140)
        {
            dY -= 1.0 * (4) / ACCURACY_CHECK;
        }
        else if(movement >= 140 && movement < 160)
        {
            dY += 1.0 * (4 + offset%3) / ACCURACY_CHECK;
            dX += 1.0 * (4 + offset%6) / ACCURACY_CHECK;
        }
        else if(movement >= 160 && movement < 180)
        {
            dX += 1.0 * (5 + offset%3) / ACCURACY_CHECK;
        }
        if(getCenterX() > SCREEN_WIDTH)
        {
            enemy.popElement(index);
            indexChange--;
        }
    }

    /*ID 2 (SpiderRight)*/
    else if(idNumber==2)
    {
        int movement = (frame+(offset+50)*7) % 180;
        if(movement >= 0 && movement < 20)
        {
            dX -= 1.0 * (4 + offset%2) / ACCURACY_CHECK;
            dY -= 1.0 * (4 + offset%3) / ACCURACY_CHECK;
        }
        else if(movement >= 20 && movement < 40)
        {
            dX -= 1.0 * (4 + offset%3) / ACCURACY_CHECK;
            dY += 1.0 * (4 + offset%2) / ACCURACY_CHECK;
        }
        else if(movement >= 40 && movement < 60)
        {
            dY -= 1.0 * (5 + offset%3) / ACCURACY_CHECK;
        }
        else if(movement >= 60 && movement < 80)
        {
            dY += 1.0 * (5 + offset%2) / ACCURACY_CHECK;
        }
        else if(movement >= 80 && movement < 100)
        {
            dX -= 1.0 * (4 + offset%4) / ACCURACY_CHECK;
            dY += 1.0 * (4) / ACCURACY_CHECK;
        }
        else if(movement >= 100 && movement < 120)
        {
            dX -= 1.0 * (4 + offset%2) / ACCURACY_CHECK;
            dY -= 1.0 * (4 + offset%2) / ACCURACY_CHECK;
        }
        else if(movement >= 120 && movement < 140)
        {
            dY -= 1.0 * (4) / ACCURACY_CHECK;
        }
        else if(movement >= 140 && movement < 160)
        {
            dY += 1.0 * (4 + offset%3) / ACCURACY_CHECK;
            dX -= 1.0 * (4 + offset%6) / ACCURACY_CHECK;
        }
        else if(movement >= 160 && movement < 180)
        {
            dX -= 1.0 * (5 + offset%3) / ACCURACY_CHECK;
        }
        if(getCenterX() < 0)
        {
            enemy.popElement(index);
            indexChange--;
        }
    }

    /*ID 3 (Flea)*/
    else if(idNumber==3)
    {
        dY += 1.0 * (9 + offset%4) / ACCURACY_CHECK;
        if(getCenterY() > SCREEN_HEIGHT)
        {
            enemy.popElement(index);
            indexChange--;
        }
    }

    /*ID 4 (Mushroom)*/
    else if(idNumber==4)
    {
        if(health == 3 && ammoCooldown == 0)
        {
            if(image) SDL_FreeSurface(image);
            imgLoadAlpha(image, "Images/Enemies/mushroom2.png");
            ammoCooldown = 10;
        }
        else if(health == 2 && ammoCooldown <= 10)
        {
            if(image) SDL_FreeSurface(image);
            imgLoadAlpha(image, "Images/Enemies/mushroom3.png");
            ammoCooldown = 20;
        }
        else if(health == 1 && ammoCooldown <= 20)
        {
            if(image) SDL_FreeSurface(image);
            imgLoadAlpha(image, "Images/Enemies/mushroom4.png");
            ammoCooldown = 30;
        }
    }

    /*ID 5 (ScorpionLeft)*/
    else if(idNumber==5)
    {
        dX += 1.0 * (4 + offset%2) / ACCURACY_CHECK;
        if(getCenterX() > SCREEN_WIDTH)
        {
            enemy.popElement(index);
            indexChange--;
        }
    }

    /*ID 6 (ScorpionRight)*/
    else if(idNumber==6)
    {
        dX -= 1.0 * (4 + offset%2) / ACCURACY_CHECK;
        if(getCenterX() < 0)
        {
            enemy.popElement(index);
            indexChange--;
        }
    }
    if(!indexChange) updatePos();
    return indexChange;
}

Enemy::Enemy(const Enemy& other)
{
    imgLocation             = other.imgLocation;
    imgLoadAlpha(image, imgLocation);
    idNumber                = other.idNumber;
    health                  = other.health;
    healthMax               = other.healthMax;
    value                   = other.value;
    dX                      = other.dX;
    dY                      = other.dY;
    updatePos();
    setRect();
    ammoCooldown            = other.ammoCooldown;
    damage                  = other.damage;
    selfDamage              = other.selfDamage;
    offset                  = other.offset;
}

const Enemy& Enemy::operator= (const Enemy& other)
{
    if(this != &other)
    {
        imgLocation             = other.imgLocation;
        imgLoadAlpha(image, imgLocation);
        idNumber                = other.idNumber;
        health                  = other.health;
        healthMax               = other.healthMax;
        value                   = other.value;
        dX                      = other.dX;
        dY                      = other.dY;
        updatePos();
        setRect();
        ammoCooldown            = other.ammoCooldown;
        damage                  = other.damage;
        selfDamage              = other.selfDamage;
        offset                  = other.offset;
    }
    return *this;
}

Centi::Centi()
{
    //Defaults to size of 12 at position (SCREEN_WIDTH, 0)
    movementSpeed = 10.0;
    moveLeft = true;
    moveDown = true;
    int size=12;
    SDL_Rect pos;
    pos.x = SCREEN_WIDTH - 35;
    pos.y = 0;
    centipedeParts.erase(); //Just incase
    for(int i=0; i < size; i++)
    {
        if(i==0) centipedeParts.pushBack(Enemy(7, 1, 500, "Images/Enemies/centipede", 0, 400, 0, 0, true));
        else     centipedeParts.pushBack(Enemy(8, 1, 500, "Images/Enemies/centipedeBody", 0, 400, 0, 0, true));
        centipedeParts[i].setPos(pos.x+0*i, pos.y); //If creating a new centipede, all parts will start at the new position
    }
}

Centi::Centi(int size, SDL_Rect& pos)
{
    movementSpeed = 10.0;
    moveLeft = true;
    moveDown = true;
    centipedeParts.erase();
    for(int i=0; i < size; i++)
    {
        if(i==0) centipedeParts.pushBack(Enemy(7, 1, 500, "Images/Enemies/centipede", 0, 400, 0, 0, true));
        else     centipedeParts.pushBack(Enemy(8, 1, 500, "Images/Enemies/centipedeBody", 0, 400, 0, 0, true));
        centipedeParts[i].setPos(pos.x, pos.y); //If creating a new centipede, all parts will start at the new position
    }
}

void Centi::collision(list<Centi>& centipedes, int i)
{
    if(i > 0)
    {
        centipedes.pushBack(Centi(i, centipedeParts[0].getPos()));
        for(int j=0; j < i; j++) //Assign front centipede's positions to old centipede's positions
        {
            (centipedes.back()).centipedeParts[j].setPos( centipedeParts[j].getPos());
        }
    }
    if(centipedeParts.getSize() -i - 1 > 0)
    {
        centipedes.pushBack(Centi(centipedeParts.getSize() - 1 - i, centipedeParts[i+1].getPos()));
        int counter=0;
        for(int j=i+1; j < centipedeParts.getSize(); j++)
        {
            (centipedes.back()).centipedeParts[counter].setPos( centipedeParts[j].getPos());
            counter++;
        }
    }
}

void Centi::move(list<Enemy>& enemyList)
{
    int actualSpeed = int(movementSpeed / ACCURACY_CHECK);
    if(centipedeParts.getSize() > 0)
    {
        SDL_Rect newPos = centipedeParts[0].getPos();
        int newX, newY;
        int tempX, tempY;  //Used for moving the body parts
        newX = centipedeParts[0].getX();
        newY = centipedeParts[0].getY();
        if(moveLeft)
        {
            newX -= (actualSpeed);
            if(newX < 0) moveLeft = false; //If centipede has reached the edge, turn around
            newPos.x = (newX);
            newPos.y = (newY);
            if((newX < 0 || mushroomCollide(enemyList, newPos))) //If centipede collides when going left
            {
                newX = centipedeParts[0].getX(); //Reset position
                newY = centipedeParts[0].getY();
                if(moveDown)
                {
                    newY += actualSpeed * 35; //Force a movement down, since up can cause an infinite loop and backwards would be bad
                    if(newY + newPos.h + actualSpeed + 10 > SCREEN_HEIGHT) moveDown = false;
                }
                else
                {
                    newY -= actualSpeed * 35;
                    if(newY - newPos.h - actualSpeed < 0) moveDown = true;
                }
            }
        }
        else
        {
            newX += actualSpeed;
            if(newX + newPos.w > SCREEN_WIDTH) moveLeft = true; //If centipede has reached the edge, turn around
            newPos.x = (newX);
            newPos.y = (newY);
            if((newX + newPos.w > SCREEN_WIDTH || mushroomCollide(enemyList, newPos))) //If centipede collides when going left
            {
                newY = centipedeParts[0].getY();
                newX = centipedeParts[0].getX();
                if(moveDown)
                {
                    newY += actualSpeed * 35; //Force a movement down, since up can cause an infinite loop and backwards would be bad
                    if(newY + newPos.h + actualSpeed + 10 > SCREEN_HEIGHT) moveDown = false;
                }
                else
                {
                    newY -= actualSpeed * 35;
                    if(newY - newPos.h - actualSpeed < 0) moveDown = true;
                }
            }
        }
        for(int i=0; i < centipedeParts.getSize(); i++)
        {
            if(i==0)
            {
                tempX    = centipedeParts[i].getX();
                tempY    = centipedeParts[i].getY();
                newPos.x = tempX;
                newPos.y = tempY;
                centipedeParts[i].movementMemory.pushFront(newPos);
                centipedeParts[i].setX(newX);
                centipedeParts[i].setY(newY);
                newX = tempX;
                newY = tempY;
            }
            else if(centipedeParts[i-1].movementMemory.getSize() > 35) //More than 35 pixels, then move
            {
                centipedeParts[i].movementMemory.pushFront( centipedeParts[i-1].movementMemory.back() );
                centipedeParts[i-1].movementMemory.popElement( (centipedeParts[i-1].movementMemory.getSize())-1);
                centipedeParts[i].setPos( centipedeParts[i].movementMemory[0] );
            }
        }
    }
}

bool Centi::mushroomCollide(list<Enemy>& enemyList, const SDL_Rect& newPos)
{
    for(int i=0; i < enemyList.getSize(); i++)
    {
        if(enemyList[i].getIdNumber() == 4) //If enemy is a mushroom, then check collision
        {
            if(collideRect(enemyList[i].getPos(), newPos))
            {
                return true;
            }
        }
    }
    return false;
}

const Centi& Centi::operator= (Centi& other)
{
    list<Enemy> temp = other.getCentipedeParts();
    moveLeft = other.moveLeft;
    moveDown = other.moveDown;
    movementSpeed = other.movementSpeed;
    centipedeParts.erase();
    centipedeParts = temp;
    return *this;
}

/*void Centi::~Centi()
{
    ;
}*/
